package br.com.clebao.droidcontroler;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import br.com.clebao.droidcontroler.adapter.MenuAdapter;

public class DroidControleMenu extends Activity {
    /** Called when the activity is first created. */
	
	public final static int MENUFILIAL = 0;
	public final static int MENUUSUARIO = 1;
	public final static int MENUPRODUTO = 2;
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	   	
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    	
        GridView gv = (GridView) findViewById(R.id.mainMenu);
        
  
       	
        
        gv.setAdapter(new MenuAdapter(this));
        
        
        gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				
				abreTela(position);
				
			}
		});
        
    }
    
    
    private void abreTela(int positionMenu){
    	Intent in = null;
    	switch (positionMenu){
    	case MENUFILIAL:
    		in = new Intent(this, FilialPrincipal.class);
    		break;
    		
    	case MENUUSUARIO:
    		in = new Intent(this, UsuarioPrincipal.class);
    		break;
    	case MENUPRODUTO: 
    		in = new Intent(this, ProdutoPrincipal.class);
    	}
    	
    
    	
    	if (in != null){
    		startActivity(in);
    	}
    }
    
    
    
    
}